package 优先算法.模拟.提莫攻击;

/**
 *https://leetcode.cn/problems/teemo-attacking/description/
 */
public class Main {
    public static void main(String[] args) {
        Solution so = new Solution();
        int[] arr ={1,4,5,6,12,19};
        int rel = so.findPoisonedDuration(arr, 3);
        System.out.println(rel);
    }
}class Solution {
    public int findPoisonedDuration(int[] timeSeries, int duration) {
        int rel = 0;
        for(int i = 1; i < timeSeries.length; i++) {
            int temp = timeSeries[i]-timeSeries[i-1];

            if(temp >= duration){
                rel+=duration;
            }else{
                rel+=temp;
            }
        }
        return rel+duration;//最后一次也要算

    }
}
